import { Body, Controller, Delete, Get, Param, Post, Put, Query } from '@nestjs/common';
import { ApiTags } from '@nestjs/swagger';
import { CouponProduct_Service } from './couponProduct.service';
import { util_ApiResponse_Base } from '@/common/util/apiResponse';
import { util_Index_ReturnContent } from '@/common/util/index';
import {
  CouponProduct_Create_Dto,
  CouponProduct_FindAllByConponId_Dto,
  CouponProduct_Update_Dto,
} from './assets/couponProduct.dto';

@Controller('/adm/couponProduct')
@ApiTags('couponProduct 优惠券对应的平台规格')
export class CouponProduct_Controller {
  constructor(private readonly couponProduct_Service: CouponProduct_Service) {}

  @Get('/listAll')
  @util_ApiResponse_Base({
    dataType: 'dataType_ell',
  })
  async couponProduct_Admin_FindAllByConponId(@Query() query: CouponProduct_FindAllByConponId_Dto) {
    return util_Index_ReturnContent(
      await this.couponProduct_Service.couponProduct_Admin_FindAllByConponId(query),
    );
  }

  @Post('/add')
  @util_ApiResponse_Base({
    dataType: 'dataType_add',
  })
  async couponProduct_Create(@Body() body: CouponProduct_Create_Dto) {
    return util_Index_ReturnContent(await this.couponProduct_Service.couponProduct_Create(body));
  }

  @Put('/update')
  @util_ApiResponse_Base({
    dataType: 'dataType_update',
  })
  async couponProduct_Update(@Body() body: CouponProduct_Update_Dto) {
    return util_Index_ReturnContent(await this.couponProduct_Service.couponProduct_Update(body));
  }

  @Delete('/delete/:coupoId/:platformId')
  @util_ApiResponse_Base({
    dataType: 'dataType_delete',
  })
  async couponProduct_Remove(
    @Param('coupoId') coupoId: string,
    @Param('platformId') platformId: string,
  ) {
    return util_Index_ReturnContent(
      await this.couponProduct_Service.couponProduct_Remove(coupoId, platformId),
    );
  }
}
